package lxh.listdatascreenview;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import lxh.listdatascreenview.view.BaseMenuAdapter;

/**
 * Created by liuxh on 2017/7/30.
 */

public class TestAdapter extends BaseMenuAdapter {
    private Context mContext;
    private String[] mItems ={"类型","品牌","价格","更多"};

    public TestAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mItems.length;
    }

    @Override
    public View getTabView(ViewGroup parent, int position) {
        //将菜单布局加进来
        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_item_menu, parent, false);
        TextView tabView = (TextView) view.findViewById(R.id.tv_tabView);
        tabView.setText(mItems[position]);
        return view;
    }

    @Override
    public View getMenuContentView(ViewGroup parent, int position) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_item_content, parent, false);
        TextView contentView = (TextView) view.findViewById(R.id.tv_contentView);
        contentView.setText(" 内容："+mItems[position]);
        return view;
    }

    @Override
    public void setCloseMenuState(View view) {
        TextView tabView = (TextView) view.findViewById(R.id.tv_tabView);
        tabView.setTextColor(Color.BLACK);
    }

    @Override
    public void setOpenMenuState(View view) {
        TextView tabView = (TextView) view.findViewById(R.id.tv_tabView);
        tabView.setTextColor(Color.RED);
    }
}
